]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ci: Prohibit template strings in translatable files
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 18 Feb 2020 16:08:23 +0000 (17:08 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 26 Feb 2020 22:53:00 +0000 (22:53 +0000)
Sadly, xgettext's dealing with template strings is abysimal, so we
had to stop using them in files with translatable strings.

Make sure we don't accidentally sneak in template strings again(*)
and enforce that rule in a CI job.

(*) easy "mistake", considering how much nicer they are than
    String.prototype.format()

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1016

.gitlab-ci.yml
.gitlab-ci/check-template-strings.sh [new file with mode: 0755]

index 3b4d23ab9a3073a6e1a31a24d6df1fd9bad4dd8f..c7f925cc0833b56f2dc5717cb237f980e2f6a4d1 100644 (file)
@@ -53,6 +53,13 @@ potfile_check:
         - ./.gitlab-ci/check-potfiles.sh
     <<: *only_default
 
+no_template_check:
+    image: registry.gitlab.gnome.org/gnome/gnome-shell/extension-ci:v1
+    stage: review
+    script:
+        - ./.gitlab-ci/check-template-strings.sh
+    <<: *only_default
+
 build:
     image: registry.gitlab.gnome.org/gnome/mutter/master:v3
     stage: build
diff --git a/.gitlab-ci/check-template-strings.sh b/.gitlab-ci/check-template-strings.sh
new file mode 100755 (executable)
index 0000000..efa8afc
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+# find files from POTFILES.in that use js template strings
+baddies=$(grep -l '${' $(grep ^js po/POTFILES.in))
+
+if [ ${#baddies} -eq 0 ]; then
+  exit 0
+fi
+
+cat >&2 <<EOT
+
+xgettext cannot handle template strings properly, so we ban their use
+in files with translatable strings.
+
+The following files are listed in po/POTFILES.in and use template strings:
+
+EOT
+for f in $baddies; do
+  echo "  $f" >&2
+done
+echo >&2
+
+exit 1